package com.springcloud.alibaba.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * @Author:RenPu
 * @Date: 2020/6/30 10:09
 * @Version: 1.0
 * @description:
 */

@RestController
@Slf4j
public class ConsulrPaymentController {

    @Value("${server.port}")
    private String serverPort;


    @RequestMapping("/payment/consul")
    public String getConsulServerPort(){

        return "spring-cloud-consul"+serverPort+"*********"+ UUID.randomUUID().toString();
    }


    //测试手写轮询算法
    @GetMapping("/payment/lb")
    public String getServerPort(){
        return serverPort;
    }

    //测试fegin超时设置是否成功
    @GetMapping(value = "/fegin/testTimeOut")
    public String testTimeOut(){
        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return serverPort;
    }



}
